function [Cdif,Cdif_early,Cdif_late] = fn_Cdif_i(D0i,R1,delta,D0,chi,lambda,y1,y2,phi,dist_d,d_min,d_max,s_star)

C1N = fn_C1N(R1,D0i,y1);
C2N = fn_C2N(R1,D0i,lambda,y2,s_star,phi);

CF_early = fn_CF(delta,R1,D0i,y1,fn_alphaF(delta,R1,D0,chi,s_star,phi,dist_d,d_min,d_max));
CF_late  = fn_CF(delta,R1,D0i,y2,fn_alphaF(delta,R1,D0,chi,s_star,phi,dist_d,d_min,d_max));

Cdif_early = C1N - CF_early;
Cdif_late  = C2N - CF_late;

Cdif = lambda*Cdif_early + (1-lambda)*Cdif_late;

end